package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.blrs.service.enterprise.info.IEnterpriseSatisfiedService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.domain.EnterpriseSatisfied;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 客户满意度Controller
 * 
 * @author xiaoyang
 * @date 2025-01-13
 */
@RestController
@RequestMapping("/blrs/satisfied")
public class EnterpriseSatisfiedController extends BaseController
{
    @Autowired
    private IEnterpriseSatisfiedService enterpriseSatisfiedService;

    /**
     * 查询客户满意度列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EnterpriseSatisfied enterpriseSatisfied)
    {
        startPage();
        List<EnterpriseSatisfied> list = enterpriseSatisfiedService.selectEnterpriseSatisfiedList(enterpriseSatisfied);
        return getDataTable(list);
    }

    /**
     * 导出客户满意度列表
     */
    @Log(title = "客户满意度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EnterpriseSatisfied enterpriseSatisfied)
    {
        List<EnterpriseSatisfied> list = enterpriseSatisfiedService.selectEnterpriseSatisfiedList(enterpriseSatisfied);
        ExcelUtil<EnterpriseSatisfied> util = new ExcelUtil<EnterpriseSatisfied>(EnterpriseSatisfied.class);
        util.exportExcel(response, list, "客户满意度数据");
    }

    /**
     * 获取客户满意度详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(enterpriseSatisfiedService.selectEnterpriseSatisfiedById(id));
    }

    /**
     * 新增客户满意度
     */
    @Log(title = "客户满意度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EnterpriseSatisfied enterpriseSatisfied)
    {
        return toAjax(enterpriseSatisfiedService.insertEnterpriseSatisfied(enterpriseSatisfied));
    }

    /**
     * 修改客户满意度
     */
    @Log(title = "客户满意度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EnterpriseSatisfied enterpriseSatisfied)
    {
        return toAjax(enterpriseSatisfiedService.updateEnterpriseSatisfied(enterpriseSatisfied));
    }

    /**
     * 删除客户满意度
     */
    @Log(title = "客户满意度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(enterpriseSatisfiedService.deleteEnterpriseSatisfiedByIds(ids));
    }
}
